import Vue from 'vue'
import App from './App'
import store from './store'
import './static/fonts/iconfont/iconfont.css'
// import 'https://sra.weikebaba.com/Uploads/singleSale/static/fonts/iconfont/iconfont.css'
import './js_sdk/ican_H5Api/ican-H5Api.js'
Vue.prototype.$store = store

Vue.config.productionTip = false

import config from './common/config.js'
Vue.prototype.imgUrl = config.imgUrl
Vue.prototype.staticUrl = config.staticUrl
Vue.prototype.echatUrl = config.echatUrl
Vue.prototype.baseUrl = config.baseUrl

import http from './api/request.js'
Vue.prototype.$http = http

import common from './common/common.js'
Vue.prototype.$common = common
Vue.prototype.back = common.back
Vue.prototype.call = common.call
Vue.prototype.toUrl = common.toUrl
Vue.prototype.backHome = common.backHome
Vue.prototype.toGoods = common.toGoods
Vue.prototype.istoGoods = common.istoGoods

import pop from './common/pop.js'
Vue.prototype.$pop = pop;
Vue.prototype.$Toast = pop.showToastTxt;
import reg from './common/reg.js'
Vue.prototype.$reg = reg

// **********************H5分享**********************
// #ifdef H5
import jweixin from 'jweixin-module'
function H5Share(param,share_obj){
	/**
	 * param: 路由参数
	 * share_obj： 分享文案 默认startUp来的sharaData
	 * **/
	let ua = window.navigator.userAgent.toLowerCase()
	let bid = uni.getStorageSync('bid')
	let share_v_id = uni.getStorageSync('vid')
	share_v_id = share_v_id?share_v_id:''
	param = '?share_v_id='+share_v_id+'&'+param
	if (ua.match(/MicroMessenger/i) == 'micromessenger') {
		http.get({
			url: '/zzj_singleSaleApi/getJssdkConfig',
			data:{
				bid: bid
			},
		}).then(res => {
			if (res) {
				jweixin.config(res);
				let shareData;
				let logo = config.imgUrl + uni.getStorageSync('startUp').logo_img
				let title = uni.getStorageSync('startUp').title
				if(share_obj){
					shareData = share_obj
				}else{
					shareData = uni.getStorageSync('shareData')
				}
				setTimeout(function(){
					jweixin.ready(function() {
						var obj = {
							title: shareData.title?shareData.title:title,
							desc: shareData.desc?shareData.desc:'快来看看吧 ~',
							link: 'https://sra.weikebaba.com/index.php/singleSaleShop/index/veriCode/'+bid+'/reset/1'+param,
							imgUrl: shareData.imageUrl?shareData.imageUrl:logo
						}
						//分享到朋友圈
						jweixin.updateAppMessageShareData(obj);
						//分享给好友
						jweixin.updateTimelineShareData(obj);
						//分享到朋友圈
						jweixin.onMenuShareTimeline(obj);
						//分享给好友
						jweixin.onMenuShareAppMessage(obj);
						//分享到QQ
						jweixin.onMenuShareQQ(obj);
					})
				},1000)
			}
		})
	}
}
Vue.prototype.H5Share = H5Share;
// #endif
// **********************H5分享**********************



App.mpType = 'app'

const app = new Vue({
	store,
    ...App
})
app.$mount()
